package com.realshare.frame.system.model;

import java.util.Collection;
import java.util.Map;

/**
 * @author JianHao Lee
 * @description 业务层向视图层返回数据时的包装类
 * @time 0018 18/05/18 下午 4:56
 */
public class PageResult {
    private boolean success = true;
    private String message = "请求成功！";
    private Integer page = 1;//当前页
    private Integer total = 0;//总记录数
    private Integer pageSize = 20;// 每页显示记录数
    private Integer statusCode = 200;//状态码
    private Object data;//结果
    private Collection rows;//结果集
    private Collection footer;//表格页脚

    public PageResult() {
        //String page = ContextHolderUtils.getRequest().getParameter("page");
        //String rows = ContextHolderUtils.getRequest().getParameter("rows");
        //this.page = StringUtils.isEmpty(page) ? this.page : Integer.parseInt(page);
        //this.pageSize = StringUtils.isEmpty(rows) ? this.pageSize : Integer.parseInt(rows);
    }

    /**
     * 传入结果状态和结果信息
     *
     * @param success 结果状态
     * @param message 结果信息
     */
    public PageResult(boolean success, String message) {
        this.success = success;
        this.message = message;
    }

    public PageResult(String message) {
        this.success = false;
        this.message = message;
    }

    public PageResult(Map data) {
        this.data = data;
    }

    public PageResult(Collection rows) {
        this.rows = rows;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Integer getPage() {
        return page;
    }

    public void setPage(Integer page) {
        this.page = page;
    }

    public Integer getTotal() {
        return total;
    }

    public void setTotal(Integer total) {
        this.total = total;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Integer getStatusCode() {
        return statusCode;
    }

    public void setStatusCode(Integer statusCode) {
        this.statusCode = statusCode;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public Collection getRows() {
        return rows;
    }

    public void setRows(Collection rows) {
        this.rows = rows;
    }

    public Collection getFooter() {
        return footer;
    }

    public void setFooter(Collection footer) {
        this.footer = footer;
    }
}
